package com.umakr.demo.controller;

import com.fasterxml.jackson.databind.util.JSONPObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by yangliu on 2017/8/9.
 */
@RequestMapping("/demo")
@Controller
public class LogController {
    @RequestMapping("/logA")
    public ModelAndView logA() {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("log/log");
        return mav;
    }

    @RequestMapping("/logB")
    @ResponseBody
    public Object logB(String user, String password) {
        Map<String, String> map = new HashMap<>();
        map.put("user", user);
        map.put("password", password);
        System.out.println(map.get("password"));

        return map;
    }

    //    检查注册时的页面
    @RequestMapping("/logC")
    @ResponseBody
    public Object logC(String user, String password) {
        String message;
        if (user == "") {
            message = "用户名不能为空";
            return message;
        } else if (password == "") {
            message = "密码不能为空";
            return message;
        } else {
            message = "注册成功";
        }
        return message;
    }
    @RequestMapping("/logD")
    public ModelAndView logD(){
        ModelAndView mav = new ModelAndView();
        mav.setViewName("log/index");
        return mav;
    }

//    登陆成功是的页面
//    @RequestMapping("/logD")
//    @ResponseBody
//    public ModelAndView logD(String user,String password){
////        if(user == )
////        ModelAndView mav = new ModelAndView();
////        mav.setViewName("index");
//        return mav;
//}
}
